package com.neuedu.yyzx.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.neuedu.yyzx.entity.NurseContent;
import com.neuedu.yyzx.entity.NurseLevelContent;
import com.neuedu.yyzx.mapper.NurseLevelContentMapper;
import com.neuedu.yyzx.service.INurseLevelContentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 护理级别对应的护理内容 服务实现类
 * </p>
 *
 * @author dya
 * @since 2021-04-27
 */
@Service
public class NurseLevelContentServiceImpl extends ServiceImpl<NurseLevelContentMapper, NurseLevelContent> implements INurseLevelContentService {

    public boolean updateAll(NurseLevelContent nurseLevelContent) {
        UpdateWrapper updateWrapper = new UpdateWrapper();

        updateWrapper.set("nurse_level_id", nurseLevelContent.getNurseLevelId());
        updateWrapper.set("nurse_content", nurseLevelContent.getNurseContent());
        updateWrapper.set("care_cycle", nurseLevelContent.getCareCycle());
        updateWrapper.set("nurse_number", nurseLevelContent.getNurseNumber());
        updateWrapper.set("note", nurseLevelContent.getNote());
        if(nurseLevelContent.getNurseNumber()!=null){
            updateWrapper.set("nurse_number",  nurseLevelContent.getNurseNumber());
        }
        if (nurseLevelContent.getNote()!=null){

            updateWrapper.set("note", nurseLevelContent.getNote());
        }


        updateWrapper.eq("id", nurseLevelContent.getId());

        int success = getBaseMapper().update(nurseLevelContent, updateWrapper);

        return success>0;
    }
}
